package com.eric.windows.imgDispose.views;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.EView;

/**
 * <h3>Description</h3>
 * TODO
 * <h3>Author</h3> Eric
 * <h3>Date</h3> 2017/8/29 16:54
 * <h3>Copyright</h3> Copyright (c)2017 Shenzhen TLIT  Co., Ltd. Inc. All rights reserved.
 */
@EView
public class ShaderView extends View {

    private Bitmap bitmap;
    public Paint paint;
    private int[] colors;

    public ShaderView(Context context) {
        super(context);
    }

    public ShaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ShaderView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public ShaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }


    @AfterInject
    void initData(){
//        bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.pic_2);
        paint = new Paint();
//        colors = new int[]{Color.RED,Color.GREEN,Color.BLUE};
//        paint.setShader(new RadialGradient(100,100,80,colors,null, Shader.TileMode.REPEAT));
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.STROKE);
        paint.setAntiAlias(true);
        paint.setStrokeWidth(5);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//        canvas.drawBitmap(bitmap,new Matrix(),paint);

        canvas.drawColor(Color.WHITE);
        Rect rect = new Rect(10,10,200,100);

        canvas.drawRect(rect,paint);
        canvas.skew((float) Math.tan(45),0);
        canvas.drawRect(rect,paint);

    }






}


